Skip to content

[DI] Automatically applying a tag to all services implementing an int… #7983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 13, 2017

Conversation

danut007ro
Copy link
Contributor

…erface

@GuilhemN
Copy link
Contributor

GuilhemN commented Jun 11, 2017

What about adding this as a tip instead, and using the Kernel::build() in the example as it's becoming more common?

.. tip::

    To apply a tag to all your autoconfigured services extending a class or an
    interface, call ``ContainerBuilder::registerForAutoconfiguration()`` in an
    :doc:`extension </bundles/extension>` or from your kernel::

        // app/AppKernel.php
        class AppKernel extends Kernel
        {
            // ...

            protected function build(ContainerBuilder $container)
            {
                $container->registerForAutoconfiguration(CustomInterface::class)
                    ->addTag('app.custom_tag')
                ;
            }
        }

@danut007ro
Copy link
Contributor Author

Even better. Updated.

Copy link
Contributor

@GuilhemN GuilhemN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍, thanks for your first contribution!

.. tip::

To apply a tag to all your autoconfigured services extending a class or an
interface, call ``ContainerBuilder::registerForAutoconfiguration()`` in an
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can even use the method role here to create a link to the API docs:

[...] :method:`Symfony\\Component\\DependencyInjection\\ContainerBuilder::registerForAutoconfiguration` [...]

@xabbuh xabbuh added this to the 3.3 milestone Jun 11, 2017
@danut007ro
Copy link
Contributor Author

Updated, thanks @xabbuh

@weaverryan
Copy link
Member

Awesome! Thank you Daniel!

@weaverryan weaverryan merged commit c31e24c into symfony:3.3 Jun 13, 2017
weaverryan added a commit that referenced this pull request Jun 13, 2017
…menting an int… (danut007ro)

This PR was squashed before being merged into the 3.3 branch (closes #7983).

Discussion
----------

[DI] Automatically applying a tag to all services implementing an int…

…erface

Commits
-------

c31e24c Create tags.rst
e5b1758 Update tags.rst
cb545ff [DI] Automatically applying a tag to all services implementing an interface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants